/**
 * @author LKQ
 * @date 2022/2/15 11:58
 * @description
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        System.out.println(solution.calculate("ABABA"));
    }
    public int calculate(String s) {
        int x = 1, y = 0;
        for (char c : s.toCharArray()) {
            if (c == 'A') {
                x = 2 * x + y;
            }
            if (c == 'B') {
                y = 2 * y + x;
            }
        }
        return x + y;

    }
}
